<?php
	$frm_ptrtinrao = $this->frmPtrTinRao;
?>

<div class="block">
	<div class="title">
		<span>Đăng tin cho thuê</span>
	</div>
	<div class="content">
		<?php if ($this->check) {?>
			<?php echo '<form id="' . $frm_ptrtinrao->getId() . '" method="' . $frm_ptrtinrao->getMethod() . '" action="" enctype="' . $frm_ptrtinrao->getEnctype() . '" name="' . $frm_ptrtinrao->getName() . '">'; ?>
			<div class="frm-info">
				<script type="text/javascript">
					$(document).ready(function() {
						$('#avatar').val('');
						var imgUrl = '<?php echo $this->baseUrl(PUBLIC_IMG_URL . "/tmp"); ?>';
						$('#thumbnail').attr("src", '<?php echo $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/avatar_home.png'); ?>');
							
					  	$('#inputupload').uploadify({
					    	'swf'  				: '<?php echo $this->baseUrl(PUBLIC_PATH . "/scripts/uploadify/uploadify.swf");?>',
					    	'uploader'    		: '<?php echo $this->baseUrl($this->currentController . '/uploadavatar'); ?>',
						    'buttonImage' 		: '<?php echo $this->baseUrl(PUBLIC_PATH . "/scripts/uploadify/browse-btn.png"); ?>',
						    'uploadFolder' 		: '<?php echo $this->baseUrl(PUBLIC_IMG_URL . "/tmp"); ?>',
					        'multi'     		: false,
					        'auto'      		: true,
					        'fileTypeDesc' 		: 'Image Files',
					        'fileTypeExts' 		: '*.gif; *.jpg; *.jpeg; *.png', 
					        'onUploadStart'		: function(file) {
					        	fileName = $('#hidden_avatar').val();
					        	if (fileName != '') {
					        		$.ajax({
					    				'url' 	: '/member/deleteimage',
					    				'type' 	: 'post',
					    				'data' 	: {'imgUrl' : 'thumb_images_64x64', 'filename' : fileName}
					    			});
					        	}
					        },
				        	'onUploadSuccess' 	: function(file, data, response) {
				        		img = imgUrl + "/thumb_images_64x64/" + data;
					        	$('#thumbnail').attr("src", img);
					        	$('#hidden_avatar').val(data);
					        	$('#avatar').val(file.name);
				         	}
						});
					});
				</script>
				<?php 
					$html = $frm_ptrtinrao->tieu_de;
					$html .= $frm_ptrtinrao->dia_chi;
					$html .= $frm_ptrtinrao->thanh_pho;
					$html .= $frm_ptrtinrao->quan_huyen;
					$html .= $frm_ptrtinrao->avatar;
					$html .= $frm_ptrtinrao->loai_phong;
					$html .= $frm_ptrtinrao->so_nguoi_o;
					$html .= $frm_ptrtinrao->dien_tich;
					$html .= $frm_ptrtinrao->gia_phong;
					$html .= $frm_ptrtinrao->gia_dien;
					$html .= $frm_ptrtinrao->gia_nuoc;
					$html .= $frm_ptrtinrao->loai_tin;
					$html .= $frm_ptrtinrao->mo_ta;
					echo $html;
				?>
				<div class="line-break"></div>
				<p class="head-contact">Thông tin liên hệ</p>
				<div class="contact-info">
					<?php
						$html = $frm_ptrtinrao->nguoi_lien_he; 
						$html .= $frm_ptrtinrao->so_dien_thoai;
						echo $html;
					?>
					<div class="line-break"></div>
				</div>
				<p class="head-contact">Thông tin khác</p>
				<div class="tabs">
					<ul class="nav nav-tabs">
						<li class="pane1 active"><a href="#map-pane1" data-toggle="tab">Bản đồ</a></li>
						<li class="pane2"><a href="#slideshow-pane2" data-toggle="tab">Hình ảnh</a></li>
						<li class="pane3"><a href="#video-pane3" data-toggle="tab">Video</a></li>
					</ul>
					<div class="view-content">
						<div class="tab-content">
							<!-- Nội dung của tab map -->
							<div class="tab-pane active" id="map-pane1">
								<div class="box-input">
									<dl>
										<dt class="map"><label>Tọa độ</label></dt>
										<dd class="map">
											<?php 
												echo $frm_ptrtinrao->latitude->renderViewHelper() . " ";
												echo $frm_ptrtinrao->longitude->renderViewHelper(); 
											?>
										</dd>
									</dl><br/>
									<div class="clear"></div>
								</div>
								<div id="map_canvas"></div>
							</div>
							<!-- Nội dung của tab slideshow hình ảnh -->
							<div class="tab-pane" id="slideshow-pane2">
								<script type="text/javascript">
									$(document).ready(function() {
										$('#slideshow').val('');
										var count = 0;
										var imgUrl = '<?php echo $this->baseUrl(PUBLIC_IMG_URL . "/tmp"); ?>';
									  	$('#file_upload').uploadify({
									    	'swf'  				: '<?php echo $this->baseUrl(PUBLIC_PATH . "/scripts/uploadify/uploadify.swf");?>',
									    	'uploader'    		: '<?php echo $this->baseUrl($this->currentController . '/uploadify'); ?>',
										    'buttonImage' 		: '<?php echo $this->baseUrl(PUBLIC_PATH . "/scripts/uploadify/browse-btn.png"); ?>',
										    'uploadFolder' 		: '<?php echo $this->baseUrl(PUBLIC_IMG_URL . "/tmp"); ?>',
									        'multi'     		: true,
									        'auto'      		: true,
									        'uploadLimit' 		: 5,
									        'fileTypeDesc' 		: 'Image Files',
									        'fileTypeExts' 		: '*.gif; *.jpg; *.jpeg; *.png', 
								        	'onUploadSuccess' 	: function(file, data, response) {
									        	count++;
									        	if (count == 1) {
									        		img = imgUrl + "/full_images/" + data;
										        	$('#slideshow_image').append("<div class='content-image'><img class='first-image' src='" + img + "' /><button class='close' type='button'>×</button></div>");
										        	$('#listImage').val(data);
										        	$('#slideshow').val(file.name);
									        	} else {
									        		img = imgUrl + "/thumb_images_90x70/" + data;
									        		$('#listImage').val($('#listImage').val() + ',' + data);
								            		$('#slideshow').val($('#slideshow').val() + ',' + file.name);
										        	if (count < 5)
								            			$('#small_image').append("<div class='content-image'><img class='small-image item-image' src='" + img + "' /></div>");
										        	else
										        		$('#small_image').append("<div class='content-image'><img class='small-image' src='" + img + "' /></div>");
									        	}
								         	}
										});
									});
								</script>
								<div class="box-input slideshow">
									<p class="hint"><b><u>Lưu ý</u></b>: Chỉ được up tối đa 5 ảnh.</p>
									<input id="slideshow" type="text" disabled="true" value="" name="slideshow">
									<?php echo $frm_ptrtinrao->listImage->renderViewHelper(); ?>
									<button id="file_upload" name="file_upload">Browse</button>
									<div class="clear"></div>
								</div>
								<div id="slideshow_image">
									<div id="small_image"></div>
								</div>
							</div>
							<!-- Nội dung của tab video -->
							<div class="tab-pane" id="video-pane3">
								<div class="box-input"><?php echo $frm_ptrtinrao->video_url->renderViewHelper(); ?></div>
								<div id="video"></div>
							</div>
						</div>
						<br class="clear" />
					</div>
				</div>
			</div>
			<div class="frm-button">
				<?php echo $frm_ptrtinrao->buttons; ?>
				<div class="clear"></div>
			</div>
			<?php echo '</form>'; ?>
		<?php } else {?>
			<div class="msg-error">
				<p class="msg-title">Thông báo</p>
				<?php echo $this->message; ?>
				<p>Để có thể hiểu rõ hơn về việc này bạn hãy xem <a href="http://kenhnhatro.net/quydinh" title="quy định">Quy định</a> của website.</p>
				<p>Nếu tin đăng nhà trọ của bạn chưa vượt số lượng cho phép bạn có thể vào trang <a href="http://kenhnhatro.net/lienhe" title="liên hệ">Liên hệ</a> để gửi yêu cầu hỗ trợ.</p>
			</div>
		<?php } ?>
	</div>
	<br class="clear" />
</div>